#pragma once

#include "../radar.h"
#include <functional>
#include "simradDef.h"
#include "../common/timeout_manager.hpp"

#define SIMRADARSPOKES (2048)
#define SIMRADARSPOKELEN (1024)

class SimRadar;

typedef std::function<void(radar_param&)> RadarCallback;
typedef std::function<void(const char* pSerialNumber, eAction action)> RadarListCallback;

class SimRadarManager
{
public:
    SimRadarManager(boost::asio::io_service& io_service);
    ~SimRadarManager();

    void Send(const std::string &data);
    void SetRadarChannel(unsigned int channel);

    void SetForceAddRadar(bool val);
    void Start();

    void SetRadarCallback(RadarCallback cb);
    void SetRadarListCallback(RadarListCallback cb);
private:
    void do_process_radar_data(const char*data, unsigned int length);

    void process_radar_negotiation_info(const radar_negotiation_info_t* info);

    void query_radar_timeout();
private:
    DataDelegateUdp m_query_radar_udp;

    unsigned int m_channel;

    bool m_is_add_radar;

    RadarCallback m_radar_callback;
    RadarListCallback m_radarlist_callback;

    TimeOutManager m_timeout_manager;
};